<?php

namespace App\Http\Controllers\admin;


use App\Dao\CategoryDao;
use App\Services\Code;
use function React\Promise\all;

class CategoryController extends BaseController
{
    public function lists(){

        if (getIsHasPage()){
            return  Code::message('',200,CategoryDao::get_category_page(request()->all()));
        }
        return view('admin.category.lists');
    }



    public function add(){
        if(isPost()){
            $params = request()->all();
            CategoryDao::add($params);
            return Code::message();
        }
        return view('admin.category.add');
    }


    public function update(){
        if(isPost()){
            $params = request()->all();
            CategoryDao::update($params);
            return Code::message('',200);
        }
        return  view('admin.category.edit',[
            'info'=>CategoryDao::get_one(request()->all())
        ]);
    }
}
